package com.micangcaihang.micang.mvp.task.model;

import com.micangcaihang.common.baserx.RxSchedulers;
import com.micangcaihang.common.http.ApiResult;
import com.micangcaihang.common.http.RxHelper;
import com.micangcaihang.micang.entity.PickerEntity;
import com.micangcaihang.micang.entity.TuftInfoEntity;
import com.micangcaihang.micang.http.ApiService;
import com.micangcaihang.micang.http.request.TaskTuftRequest;
import com.micangcaihang.micang.mvp.task.contract.TaskTuftInfoContract;

import java.util.List;

import io.reactivex.Observable;

/**
 * <pre>
 *     author : Fandy
 *     e-mail : fandayongfly@gmail.com
 *     time   : 2017/07/17
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class TaskTuftInfoModel implements TaskTuftInfoContract.Model {
    /**
     * 加载待处理任务列表
     *
     * @param id
     * @return
     */
    @Override
    public Observable<ApiResult<TuftInfoEntity>> getTuftInfoData(String id) {
        return ApiService.<ApiResult<TuftInfoEntity>>invest_houseproperty(id)
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 环路区间方向
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getRingRdDirection() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("ring_rd_direction")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 房屋结构
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getRoomConstruction() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("room_construction")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 环路区间环数
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getCirclePosition() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("circle_position")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 房屋用途
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getHouseUse() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("house_use")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 产权类型
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getPropertyRightType() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("property_right_type")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 房屋朝阳
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getHourseOrientation() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("hourse_orientation")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 装修状况
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getFitmentStatus() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("fitment_status")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 建筑类型
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getStructureType() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("structure_type")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 使用状态
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getUseinStatue() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("usein_statue")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 整体结构
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getStructureModify() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("structure_modify")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 唯一房产
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getIsOnlyHouse() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("is_only_house")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 购买年数
     *
     * @return
     */
    @Override
    public Observable<ApiResult<List<PickerEntity>>> getPurchaseYear() {
        return ApiService.<ApiResult<List<PickerEntity>>>util_choose("purchase_year")
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 保存信息
     *
     * @param request
     * @return
     */
    @Override
    public Observable<ApiResult<Void>> savaTuftInfo(TaskTuftRequest request) {
        return ApiService.<ApiResult<Void>>invest_propertyupdate(request)
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }
}
